package com.cml.dm.admin.service.handler;

import com.cml.dm.admin.entity.DmExeLogger;
import com.cml.dm.admin.entity.DmMetadata;
import lombok.Data;

@Data
public abstract class TaskHandler {
    private TaskHandler nexTaskHandler;

    private DmExeLogger exeLogger;

    protected abstract void execute(DmMetadata dmMetadata, DmExeLogger dmExeLogger, Object extParameter);

    public void doExecute(DmMetadata dmMetadata, DmExeLogger dmExeLogger, Object extParameter){
        TaskHandler handler = this;
        handler.execute(dmMetadata, dmExeLogger, extParameter);
        while (null != handler.getNexTaskHandler()){
            handler = handler.getNexTaskHandler();
            handler.execute(dmMetadata, handler.getExeLogger(), extParameter);
        }
    }

    public DmExeLogger getExeLogger() {
        return exeLogger;
    }

    public void setExeLogger(DmExeLogger exeLogger) {
        this.exeLogger = exeLogger;
    }
}
